package com.djhu.freepartner.web.control.manager;

import com.djhu.freepartner.bean.PartnerUser;
import com.djhu.freepartner.web.service.session.ISessionService;
import com.djhu.freepartner.web.support.SpringContextHolder;

public class SessionManager {

    private final static SessionManager me = new SessionManager();

    private  ISessionService defaultSessionService = SpringContextHolder.getBean(ISessionService.class);

    public static SessionManager me() {
        return me;
    }

    private SessionManager() {
    }

    public SessionManager(ISessionService checkFactory) {
        this.defaultSessionService = defaultSessionService;
    }

    public void setDefaultCheckFactory(ISessionService sessionService) {
        this.defaultSessionService = sessionService;
    }


    public String buildSession(PartnerUser partnerUser){
        return defaultSessionService.createSessionId(partnerUser);
    }

    public  PartnerUser selectUserBySessionId(String sessionId){
        return defaultSessionService.selectUserBySessionId(sessionId);
    }

    public  PartnerUser addPartnerUserToSession(PartnerUser partnerUser){
        return defaultSessionService.addPartnerUserToSession(partnerUser);
    }

    public void deleteSessionByUser(PartnerUser user) {
        defaultSessionService.deleteSession(user);
    }
}
